package cn.source.web.controller.zk;

import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.zk.domain.entity.Cxdz;
import cn.source.zk.service.IZkCxdzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/zk/cxdz")
public class ZkCxdzController extends BaseController {

    @Autowired
    private IZkCxdzService cxdzService;

    /**
     * 获取csdz列表
     * @param cxdz
     * @return
     */
    @GetMapping("/list")
    private AjaxResult getList(Cxdz cxdz){

        List<Cxdz> list = cxdzService.getList(cxdz);

        return AjaxResult.success(list);
    }

    @GetMapping("/{num}")
    private AjaxResult getCxdzByNum(@PathVariable Long num){
        Cxdz cxdz = cxdzService.getCxdzByNum(num);
        return AjaxResult.success(cxdz);
    }

    @PostMapping()
    private AjaxResult add(@RequestBody Cxdz cxdz){
        return toAjax(cxdzService.add(cxdz));
    }

    @PutMapping()
    private AjaxResult edit(@RequestBody Cxdz cxdz){
        return toAjax(cxdzService.edit(cxdz));
    }

    @DeleteMapping("/{tdGuids}")
    private AjaxResult removeBatch(@PathVariable List<String> tdGuids){
        return toAjax(cxdzService.removeBatch(tdGuids));
    }

    @PutMapping("/refresh")
    private AjaxResult refreshCxdz(@RequestBody Cxdz cxdz){
        return toAjax(cxdzService.refreshCxdz(cxdz));
    }
}
